package com.weishu.auth.config;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * Ajax接口统一的返回结果
 * @author zhanggm
 * @date 2021/8/18 16:34
 */

@Data
@AllArgsConstructor
@NoArgsConstructor
public class AjaxResult {

    //ajax接口是否正常相应
    private boolean result;
    //接口返回数据
    private Object data;
    //错误编码
    private int errCode;
    //错误提示
    private String message;

    /**
     * 正常消息返回
     * @return
     */
    public static AjaxResult ok(){
        return new AjaxResult(true, null, 0, null);
    }

    public static AjaxResult ok(Object data){
        return new AjaxResult(true, data, 0, null);
    }

    /**
     * 错误相应
     * @return
     */
    public static AjaxResult err(){
        return new AjaxResult(false, null, 0, null);
    }

    public static AjaxResult err(Integer errCode,String message){
        return new AjaxResult(false, null, errCode, message);
    }

}
